package o;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.BaseTitleBean;
import com.huawei.appgallery.foundation.ui.framework.widget.NetworkRemindBar;
import com.huawei.appgallery.foundation.ui.framework.widget.NetworkRemindBar.c;
import com.huawei.appmarket.R;
import com.huawei.appmarket.framework.fragment.MainBackTitle;
import com.huawei.appmarket.service.appmgr.view.activity.AppManagerProtocol;
import com.huawei.appmarket.service.settings.view.widget.EnterLayout;

public class dhk implements cja {
    private ProgressBar ʻ;
    private NetworkRemindBar ʼ;
    private View ʽ;
    public boolean ˊ = false;
    private boolean ˊॱ = false;
    private boolean ˋ = false;
    public boolean ˎ = false;
    protected LinearLayout ˏ;
    protected View ॱ;
    private int ॱˊ = -1;
    private int ॱॱ = 0;
    private OnClickListener ᐝ;

    public dhk ˏ(int i) {
        this.ॱˊ = i;
        return this;
    }

    public View ˏ(LayoutInflater layoutInflater) {
        View inflate = layoutInflater.inflate(R.layout.startup_loading_fragment, null);
        evf.ॱ(inflate, (int) R.color.emui_white);
        ˋ(inflate);
        inflate.setVisibility(8);
        return inflate;
    }

    public void ˋ(View view) {
        View findViewById = view.findViewById(R.id.titlebar);
        if (findViewById instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) findViewById;
            BaseTitleBean baseTitleBean = new BaseTitleBean();
            baseTitleBean.ॱ(view.getContext().getString(R.string.app_name));
            View ˋ = new MainBackTitle((Activity) view.getContext(), baseTitleBean).ˋ();
            if (ˋ != null) {
                viewGroup.setVisibility(0);
                viewGroup.addView(ˋ);
            }
        }
        this.ॱ = view;
        this.ʻ = (ProgressBar) view.findViewById(R.id.loadingBar);
        this.ʽ = view.findViewById(R.id.loadingBar_layout);
        evf.ॱ(this.ʽ, (int) R.color.emui_white);
        this.ˏ = (LinearLayout) view.findViewById(R.id.tipslayout);
        this.ˎ = true;
        if (this.ˋ) {
            ˊ(this.ॱॱ);
        } else {
            ˊ();
        }
    }

    private void ˋ() {
        this.ˏ.removeAllViews();
        if (this.ॱ != null && this.ॱ.getContext() != null) {
            LayoutInflater layoutInflater = (LayoutInflater) this.ॱ.getContext().getSystemService("layout_inflater");
            if (layoutInflater != null) {
                View inflate = layoutInflater.inflate(R.layout.startup_loading_fragment_scrollview, this.ˏ);
                evf.ॱ(inflate, (int) R.color.emui_white);
                this.ʼ = (NetworkRemindBar) inflate.findViewById(R.id.network_remind_bar);
                azb.ˏ(inflate, R.id.item_title);
                this.ʼ.setNetworkRemindBarListener(new c(this) {
                    final /* synthetic */ dhk ˊ;

                    {
                        this.ˊ = r1;
                    }

                    public void ﾟॱ() {
                        this.ˊ.ˊ();
                        this.ˊ.ᐝ.onClick(this.ˊ.ˏ);
                    }

                    public void ﹶ() {
                    }

                    public void ʳ() {
                    }
                });
                EnterLayout enterLayout = (EnterLayout) this.ˏ.findViewById(R.id.uninstallBtn);
                enterLayout.setTitle(Integer.valueOf(R.string.install_manager_title_ex));
                enterLayout.setIcon(R.drawable.wisedist_manager_ins_nor);
                enterLayout.setMemoVisibility(8);
                enterLayout.setOnClickListener(new OnClickListener(this) {
                    final /* synthetic */ dhk ˎ;

                    {
                        this.ˎ = r1;
                    }

                    public void onClick(View view) {
                        cjk.ˎ().ˋ(this.ˎ.ॱ.getContext(), new AppManagerProtocol().ˎ());
                    }
                });
                enterLayout = (EnterLayout) this.ˏ.findViewById(R.id.apkmanagerBtn);
                enterLayout.setTitle(Integer.valueOf(R.string.apk_management));
                enterLayout.setIcon(R.drawable.wisedist_manager_ins_pac_nor);
                enterLayout.setMemoVisibility(8);
                enterLayout.setLastLineGone();
                enterLayout.setOnClickListener(new OnClickListener(this) {
                    final /* synthetic */ dhk ˋ;

                    {
                        this.ˋ = r1;
                    }

                    public void onClick(View view) {
                        cjk.ˎ().ˋ(this.ˋ.ॱ.getContext(), new cjm("apkmgr.activity", null));
                    }
                });
                this.ˊ = true;
            }
        }
    }

    public void ˋ(int i, boolean z) {
        Logger.ˋ("ColorfulLoadingController", "stopLoading(netErrorCode=" + i + ",bRetry=" + z + ")");
        if (!this.ˊॱ) {
            if (!z) {
                this.ˊॱ = true;
            }
            this.ˋ = true;
            this.ॱॱ = i;
            if (this.ʻ != null) {
                this.ʻ.setVisibility(8);
            }
            if (this.ʽ != null) {
                this.ʽ.setVisibility(8);
            }
            if (this.ˏ != null) {
                this.ˏ.setVisibility(0);
            }
            if (i == 0) {
                if (this.ॱ != null) {
                    this.ॱ.setVisibility(8);
                }
            } else if (this.ˎ) {
                ˋ(0);
                if (this.ʼ != null) {
                    this.ʼ.ॱ(i);
                }
            }
        }
    }

    private void ˊ(int i) {
        Logger.ˋ("ColorfulLoadingController", "stopLoading() netErrorCode : " + i);
        this.ˋ = true;
        if (this.ʻ != null) {
            this.ʻ.setVisibility(8);
        }
        if (this.ʽ != null) {
            this.ʽ.setVisibility(8);
        }
        if (this.ˏ != null) {
            this.ˏ.setVisibility(0);
        }
        if (this.ˎ) {
            ˋ(0);
            if (this.ʼ != null) {
                this.ʼ.ॱ(i);
            }
        }
    }

    public void ˋ(OnClickListener onClickListener) {
        this.ᐝ = onClickListener;
    }

    public void ˊ() {
        if (this.ʽ != null) {
            this.ʽ.setVisibility(0);
        }
        if (this.ʻ != null) {
            this.ʻ.setVisibility(0);
        }
        if (this.ˏ != null) {
            this.ˏ.setVisibility(8);
        }
    }

    public void ˏ() {
        ˋ(0);
    }

    public boolean ˎ() {
        return this.ʼ != null && this.ʼ.getVisibility() == 0;
    }

    public void ˋ(int i) {
        if (this.ˎ && this.ॱ != null) {
            this.ॱ.setVisibility(i);
            if (i == 0 && !this.ˊ) {
                ˋ();
            }
        }
    }

    public void onEvent(int i) {
        if (i != 0) {
            ˋ(i, true);
        } else if (this.ॱ == null || this.ॱ.getVisibility() != 8) {
            ˋ(8);
        }
    }
}
